package com.yic.module.mes.api;

import cn.hutool.core.collection.CollectionUtil;
import com.yic.module.mes.api.plan.PlanApi;
import com.yic.module.mes.api.plan.dto.PlanRespDTO;
import com.yic.module.mes.convert.plan.PlanConvert;
import com.yic.module.mes.dal.dataobject.plan.PlanDO;
import com.yic.module.mes.service.plan.PlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @Author: Ljx
 * @createTime: 2023年12月26日 08:53:14
 * @version: v1.0.0
 * @Description: 生产计划API实现
 */
@Service
public class PlanApiImpl implements PlanApi {

    @Resource
    private PlanService planService;

    @Override
    public PlanRespDTO getPlan(Long id) {
        if (id == null) {
            return null;
        }
        PlanDO plan = planService.getPlan(id);
        return PlanConvert.INSTANCE.convert01(plan);
    }

    @Override
    public List<PlanRespDTO> getPlanList(Collection<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        List<PlanDO> planList = planService.getPlanList(ids);
        return PlanConvert.INSTANCE.convertList03(planList);
    }
}
